// @Author EthanScriptOn
// @Desc
package pool

import (
	"gitee.com/fatzeng/srf_switch_basic_components/queue"
)

// Task A task interface, a task that can be executed by a worker
type Task interface {
	// Execute The execution interface of the task returns an error directly in it
	Execute() error
}

// Worker Worker interface
type Worker interface {
	// GetWeight Get weights
	GetWeight() int
	// GetLoadFactor Get the load situation
	GetLoadFactor() float64
	// GetQueue Get the queue
	GetQueue() queue.Queue
	// Submit Submit a task
	Submit(task Task)
	// Destroy Destroy the worker
	Destroy()
	// Initialization Initialize the worker
	Initialization() error
}

// WorkerFactory The worker factory is responsible for creating workers
type WorkerFactory interface {
	Create() (Worker, error)
}

// RejectStrategy worker's rejection policy
type RejectStrategy interface {
	Reject(task Task, workerPool *WorkerPool)
}
